package com.example.research.service;

import com.example.research.model.Teacher;
import com.example.research.repository.TeacherRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class TeacherService {
    @Autowired
    private TeacherRepository teacherRepository;

    public List<Teacher> findAll() {
        return teacherRepository.findAll();
    }

    public Teacher save(Teacher teacher) {
        return teacherRepository.save(teacher);
    }

    public void delete(Integer id) {
        teacherRepository.deleteById(id);
    }

    public Teacher findById(Integer id) {
        return teacherRepository.findById(id).orElse(null);
    }

    public List<Teacher> findByDepartment(Integer deptId) {
        return teacherRepository.findByDepartmentDeptId(deptId);
    }
}